package com.bsy.videostation.manager

import androidx.lifecycle.LiveData
import com.bsy.framework.ext.data
import com.bsy.videostation.model.res.UserInfo

/**
 * Created by Sincerity on 2024/5/31.
 * Copyright
 * 描述：
 */
object UserServiceManager {
    private val userService: UserManager by lazy { UserManager() }

    /**
     * 清除用户信息
     */
    fun clearUserInfo() {
        userService.clearUserInfo()
    }

    /**
     * 是否登录
     */
    fun isLogin(): Boolean {
        return userService.isLogin().data()
    }

    /**
     * 保存用户信息
     */
    fun saveUserInfo(userInfo: UserInfo?) {
        userService.saveUserInfo(userInfo)
    }

    /**
     * 获取用户信息
     */
    fun getUserInfo(): UserInfo? {
        return userService.getUserInfo()
    }

    /**
     * 获取token
     */
    fun getToken(): String {
        return userService.getToken()
    }

    /**
     * 获取token
     */
    fun saveToken(token: String) {
        userService.saveToken(token)
    }

    /**
     * 保存登录状态
     */
    fun saveLogin(isLogin: Boolean) {
        userService.saveLogin(isLogin)
    }

    /**
     * 获取User信息LiveData
     */
    fun getUserLiveData(): LiveData<UserInfo?>? {
        return userService.getUserLiveData()
    }
}